from pylab import *
from rapameters import *
from oscillator import *
from copy import *
from time import *
from raptools import *
from wave import Wave
from random import *;


i = int(sys.argv[1])
j = float(sys.argv[2])
print i
print j

print sys.argv

OSC_LIFETIME        = 3
TIME                = 240;
DT                  = 1;

#                     
print             '[0tau, 1rp, 2rm, 3qp, 4qm, 5m,  6n,  7k]'
rarray        = [1.0 for i in range(8)];
rarray        = [10.0,1.9,0.5,0.4,0.4,3.5,6.0,1.0];
rarray = [10.827473246818583, 30.341344987106659, 38.084482088400321, 23.176559639378645, 13.132611039451312, 27.547732473670827, 12.230524995810372, 18.123501513193965]
rarray = [2.7856815991959825, 2.0255899739638923, 5.9240073825800623, 2.3763272436289213, 1.0753192639557796, 3.0584585336821699, 7.9131403514129639, 8.4184853901174002]
rarray = [1.0213329520732266, 8.960069635088745, 1.9314323996440903, 9.9363613403908158, 3.2435580055296818, 15.269412069047291, 0.018162427989510954, 5.5562083041616814]
rarray = [20.401026486857788, 46.952922052080886, 1.9244537343427681, 5.4314954025026525, 32.515247526748723, 22.505494547910427, 5.1135101026976884, 0.66732300708069026]
rarray  = [2.9118639218713445, 1.5554150936026889, 7.8913862289017658, 3.1992969764114743, 3.5530542749064753, 5.7203164591528628, 21.813417893268653, 3.2697420030617361]
rarray = [2.7341742113545444, 1.5942782945537024, 2.0474922918289802, 0.83397498892234401, 0.80062079956157539, 1.8037368881647122, 1.9966537232482726, 0.038825240512401105]
rarray = [1.0047078522687474, 3.9595799577360298, 4.4264115902126591, 2.1212718145707354, 2.2576969003727232, 5.2666206485485212, 1.6779606057058341, 1.8639131516845002]
rarray = [2.5087423176550514, 4.1664996986144693, 2.8499933400780995, 0.92626876280075454, 0.59643465006540042, 3.3956690116510835, 1.7526387740451741, 2.0134843268252269]

i = 0
rarray2 = deepcopy(rarray);
rarray2[i] = rarray2[i]*j; 
print rarray2

start = Oscillator(rarray,TIME,DT,OSC_LIFETIME)
spt = start.get_times();
spv = start.get_vals();

change = Oscillator(rarray2,TIME,DT,OSC_LIFETIME)
cpt = change.get_times();
cpv = change.get_vals();

print "----------------------------------------------------------"
print 'OSCILLATOR : START', id(start), ' (BLUE)'
print "----------------------------------------------------------"
print 'amp: ',start.get_amp();
print 'frq: ', start.get_frq();
print 'time up: ',start.get_tim_up();
print 'time down: ',start.get_tim_down();
print 'parameters', start.get_rapams();
print ""

print "----------------------------------------------------------"
print 'OSCILLATOR : CHANGE', id(change), ' (BLUE)'
print "----------------------------------------------------------"
print 'amp: ',change.get_amp();
print 'frq: ', change.get_frq();
print 'time up: ',change.get_tim_up();
print 'time down: ',change.get_tim_down();
print 'parameters', change.get_rapams();
print ""

print "----------------------------------------------------------"
print 'D'
print "----------------------------------------------------------"
print 'damp: ', change.get_amp() - start.get_amp();
print 'dfrq: ', change.get_frq() - start.get_frq();

plot(spt, spv, linewidth=1.0, color = 'blue')
plot(cpt, cpv, linewidth=1.0, color = 'red')

show();